package org.luxor.commons.schedule.service.impl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import org.luxor.commons.core.utils.IdWorker;
import org.luxor.commons.schedule.entity.ScheduleJobEntity;
import org.luxor.commons.schedule.service.IScheduleJobService;

import java.util.LinkedHashMap;
import java.util.Map;

/**
 * 调度任务 默认实现类
 *
 * @author Mr.yan @date 2020/2/24
 */
public class ScheduleJobNoneServiceImpl implements IScheduleJobService {
    private final LinkedHashMap<String, Long> jobIds = new LinkedHashMap<>(15);

    @Override
    public IPage<ScheduleJobEntity> page(IPage<ScheduleJobEntity> page, Map search) {
        return page;
    }

    @Override
    public Long getLogId(String beanName, String methodName) {
        String jobKey = String.join("_", beanName, methodName);
        Long jobId = jobIds.get(jobKey);
        if (jobId == null) {
            jobId = IdWorker.getId();
            jobIds.put(jobKey, jobId);
        }
        return jobId;
    }

    @Override
    public void saveJob(ScheduleJobEntity scheduleJob) {

    }

    @Override
    public void update(ScheduleJobEntity scheduleJob) {

    }

    @Override
    public void deleteBatch(Long[] jobIds) {

    }

    @Override
    public int updateBatch(Long[] jobIds, int status) {
        return 0;
    }

    @Override
    public void run(Long[] jobIds) {

    }

    @Override
    public void pause(Long[] jobIds) {

    }

    @Override
    public void resume(Long[] jobIds) {

    }
}
